import request from '@/config/axios'

// 事项类别 VO
export interface MatterCategoryVO {
  id: number // 类别id
  parentId: number // 父类别id
  name: string // 类别名称
  sort: number // 排序
  remark: string // 备注
  status: string // 状态
}

// 事项类别 API
export const MatterCategoryApi = {
  // 查询事项类别分页
  getMatterCategoryPage: async (params: any) => {
    return await request.get({ url: `/ehs/matter-category/page`, params })
  },
  getMatterCategoryList: async (params: any) => {
    return await request.get({ url: `/ehs/matter-category/list`, params })
  },

  // 查询事项类别详情
  getMatterCategory: async (id: number) => {
    return await request.get({ url: `/ehs/matter-category/get?id=` + id })
  },

  // 新增事项类别
  createMatterCategory: async (data: MatterCategoryVO) => {
    return await request.post({ url: `/ehs/matter-category/create`, data })
  },

  // 修改事项类别
  updateMatterCategory: async (data: MatterCategoryVO) => {
    return await request.put({ url: `/ehs/matter-category/update`, data })
  },

  // 删除事项类别
  deleteMatterCategory: async (id: number) => {
    return await request.delete({ url: `/ehs/matter-category/delete?id=` + id })
  },

  // 导出事项类别 Excel
  exportMatterCategory: async (params) => {
    return await request.download({ url: `/ehs/matter-category/export-excel`, params })
  },

  // 状态修改
  changeStatus:async (id, status) =>{
    const data = {
      id,
      status
    }
    return await request.put({ url: `/ehs/matter-category/update-status`, data })
  }
}
